<template>
	<view class="tabBar">
		<view class="item" @click="toIndex('0')">
			<image v-if="selected == 0" src="@/static/index1.png" mode="scaleToFill"></image>
			<image v-else src="@/static/index.png" mode="scaleToFill"></image>
			<text :style="{color: selected == 0 ? '#ff7437' : '#777777'}">广场</text>
		</view>
		<view class="item" @click="toIndex('1')">
			<image v-if="selected == 1" src="@/static/category1.png" mode="scaleToFill"></image>
			<image v-else src="@/static/category.png" mode="scaleToFill"></image>
			<text :style="{color: selected == 1 ? '#ff7437' : '#777777'}">钓点</text>
		</view>
		<view class="item" @click="toIndex('2')">
			<image v-if="selected == 2" src="@/static/chooseCat1.png" mode="scaleToFill"></image>
			<image v-else src="@/static/chooseCat.png" mode="scaleToFill"></image>
			<text :style="{color: selected == 2 ? '#ff7437' : '#777777'}">我的</text>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			select: "",
		},
		data() {
			return {
				selected: 0,
			};
		},
		created() {
			uni.hideTabBar({});
			if (this.select) {
				this.selected = parseInt(this.select);
			}
		},
		methods: {
			async toIndex(index) {
				uni.switchTab({
					url: {
						0: "/pages/index/index",
						1: "/pages/shopping/shopping",
						2: "/pages/community/community",
					} [index],
				});
			},
		},
	};
</script>

<style lang="scss" scoped>
	* {
		line-height: 1;
		box-sizing: border-box;
	}
	.tabBar{
		  display: flex;
		  justify-content: space-between;
		  align-items: center;
		  position: fixed;
		  bottom: -4rpx;
		  left: 0;
		  z-index: 888;
		  width: 100%;
		  height: 111rpx;
		  background-color: #fff;
		  background-size: 100% 100%;
		  .item{
			  display: flex;
			  flex-direction: column;
			  align-items: center;
			  flex: 1;
			  image {
				  width: 50rpx;
				  height: 50rpx;
				  margin-bottom: 5rpx;
			  }
			  text{
				  font-size: 22rpx;
				  font-weight: 400;
				  color: #777777;
				  line-height: 26rpx;
			  }
		  }
	}
</style>